import random
from symbol import decorator


def get_keys(dicts, value):
    return [k for k, v in dicts.items() if v == value]


dict1 = {
    'one': 1,
    'two': 2,
    'three': 3,
    'four': 4,
    "一": 1
}
print(get_keys(dict1, 1))

print("------------- 参数的收集 --------------")


def foot(*args):
    print(args, len(args))
    print(*args)
    print("--")


print("-------")
foot(1, 2, 3)
foot((1, 2, 3))
foot(*(1, 2, 3))
foot([1, 2, 3])
foot(*[1, 2, 3])


def foot2(**kwargs):
    print(kwargs, len(kwargs))
    print(*kwargs)
    print("--")


print("-------")
foot2(**{"name": "xiaobai", "pwd": "123456"})
foot2(name="xiaobai", pwd="123456")

print("------------- 装饰器 --------------")


def my_random(func):
    def wrapper(*args, **kwargs):
        # return func
        print("before")
        return func(*args, **kwargs)
    print("after")
    return wrapper


@my_random
def hello(name):
    print("hello, {}".format(name))


hello("xiaobai")

